/**
 * 
 */
package core;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

/**
 * @author Xiaohui
 * 
 */
public class PairTimeObjList implements Comparable{

	public int timeStamp;
	public List<Integer> objids;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		PairTimeObjList[] ps = new PairTimeObjList[4];
		List<Integer> temp1 =new LinkedList<Integer>();
		List<Integer> temp2 =new LinkedList<Integer>();
		List<Integer> temp3 =new LinkedList<Integer>();
		List<Integer> temp4 =new LinkedList<Integer>();
		temp1.add(11);
		temp2.add(21);
		temp3.add(31);
		
		temp4.add(41);
		temp4.add(42);
		
		PairTimeObjList p1 = new PairTimeObjList(4, temp4);
		PairTimeObjList p2 = new PairTimeObjList(1, temp1);
		PairTimeObjList p3 = new PairTimeObjList(3, temp3);
		PairTimeObjList p4 = new PairTimeObjList(2, temp2);
		ps[0] = p1;
		ps[1]=p2;
		ps[2] =p3;
		ps[3] = p4;
		for (int i=0;i<4; i++){
			System.out.println(ps[i].objids.get(0));
		}
		Arrays.sort(ps);
		for (int i=0;i<4; i++){
			System.out.println(ps[i].objids.get(0));
		}
	}
	
	public PairTimeObjList(int timeStamp, List<Integer> objids) {
		this.timeStamp = timeStamp;
		this.objids = objids;
	}
	@Override
	public int compareTo(Object anotherPair) {
		if (!(anotherPair instanceof PairTimeObjList))
		      throw new ClassCastException("A PairTimeObjList object expected.");
		int t1 = ((PairTimeObjList)anotherPair).timeStamp;
		
		return this.timeStamp - t1;
	}
}
